<?php

// Begin code for form mail
	function remove_wp_magic_quotes()
	{
		$_GET	 = stripslashes_deep($_GET);
		$_POST	 = stripslashes_deep($_POST);
		$_COOKIE = stripslashes_deep($_COOKIE);
		$_REQUEST= stripslashes_deep($_REQUEST);
	}
	function get_countries($file){
		//create dom document
		$doc = new DOMDocument();
		$doc->load($file);
		
		$result = array();
		
		//get country elements
		$countries = $doc->getElementsByTagName('country');
		
		if (!empty($countries))
		{
			foreach ($countries as $country)
			{
				//create cities list
				$resultCities = array();
				
				//get city elements
				$cities = $country->getElementsByTagName('city');
				foreach ($cities as $city) {
					//write city element into cities list
					$resultCities[] = $city->getAttribute('value');
				}
				
				//write cities list into country
				$result[$country->getAttribute('value')] = $resultCities;
			}
			//return countries
			return $result;
		}
		//return false if error occurred
		else false;
	}
	function get_dataXML($file, $elementName){
		//create dom document
		$doc = new DOMDocument();
		$doc->load($file);
		
		$result = array();
		
		//get elements name
		$elements = $doc->getElementsByTagName($elementName);
		
		if (!empty($elements))
		{
			foreach ($elements as $element)
			{
				$result[$element->getAttribute('value')] = $element->getAttribute('value');
			}
			//return elements
			return $result;
		}
		//return false if error occurred
		else false;
	}
	// End

?>
